package com.ailianlian.ablecisi.pojo.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * 评论数据模型
 */
public class Comment {
    private String id;
    private String content;
    private String userId;
    private String userName; // 用户名称
    private String userAvatarUrl; // 用户头像URL
    private Long createTime; // 创建时间，使用时间戳表示
    private Integer likeCount; // 点赞数
    private Boolean isLiked; // 是否已点赞
    private String parentId; // 父评论ID，如果是回复评论的话
    private List<Comment> replies; // 回复列表

    public Comment() {
        this.replies = new ArrayList<>();
    }

    public Comment(String id, String content, String userId, String userName, String userAvatarUrl, Long createTime) {
        this.id = id;
        this.content = content;
        this.userId = userId;
        this.userName = userName;
        this.userAvatarUrl = userAvatarUrl;
        this.createTime = createTime;
        this.likeCount = 0;
        this.isLiked = false;
        this.parentId = null;
        this.replies = new ArrayList<>();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserAvatarUrl() {
        return userAvatarUrl;
    }

    public void setUserAvatarUrl(String userAvatarUrl) {
        this.userAvatarUrl = userAvatarUrl;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Integer getLikeCount() {
        return likeCount;
    }

    public void setLikeCount(Integer likeCount) {
        this.likeCount = likeCount;
    }

    public Boolean getLiked() {
        return isLiked;
    }

    public void setLiked(Boolean liked) {
        isLiked = liked;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public List<Comment> getReplies() {
        return replies;
    }

    public void setReplies(List<Comment> replies) {
        this.replies = replies;
    }

    public void addReply(Comment newComment) {
        if (newComment != null) {
            newComment.setParentId(this.id); // 设置新评论的父评论ID为当前评论的ID
            this.replies.add(newComment);
        }
    }
}